﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace ObjectRelationalMap.Models
{
    public static class QueryExtensions
    {
        public static Student GetByName(this IEnumerable<Student> students, string name)
        {
            Student studentWithName;

            studentWithName = students.SingleOrDefault<Student>((student) => (student.Name == name));

            return studentWithName;
        }

        public static Domain GetByName(this IEnumerable<Domain> domains, string name)
        {
            Domain domainWithName;

            domainWithName = domains.SingleOrDefault<Domain>((domain) => (domain.Name == name));

            return domainWithName;
        }
    }
}
